// 请求拦截器：发送请求前处理
axios.interceptors.request.use(config => {
	// 动态添加 token（每次请求前更新）
	console.log(config);
	config.withCredentials = true;
	config.baseURL = 'http://10.8.0.1/v1';
	config.headers.Authorization = 'Bearer app-poPLtKUWKzDduMB6mXHOYqad';
	return config;
}, error => {
	alert('请求发送失败：' + error.message);
	return Promise.reject(error);
});

// 响应拦截器：收到响应后处理
axios.interceptors.response.use(response => {
	return response.data;
}, error => {
	// 处理错误状态码（如 401 未授权）
	if (error.response && error.response.status === 401) {
		alert('登录已过期，请重新登录');
		window.location.href = '/login';
	}
	return Promise.reject(error);
});

window.user_input_form = [{
	"select": {
		"variable": "choose_mode",
		"label": "工作模式",
		"type": "select",
		"max_length": 48,
		"required": true,
		"options": ["直接回答", "循循善诱"]
	}
}, {
	"select": {
		"variable": "style",
		"label": "语言风格",
		"type": "select",
		"max_length": 48,
		"required": true,
		"options": ["活泼的", "严谨的"]
	}
}, {
	"text-input": {
		"variable": "course",
		"label": "课程名称",
		"type": "text-input",
		"max_length": 64,
		"required": true,
		"options": [],
		"allowed_file_upload_methods": ["local_file", "remote_url"],
		"allowed_file_types": ["image"],
		"allowed_file_extensions": []
	}
}]

function handleChatAside() {
	if (this.expandStatus === 'expanded') {
		this.expandStatus = 'collapsed';
	} else if (this.expandStatus === 'collapsed') {
		this.expandStatus = 'expanded';
	} else {
		this.expandStatus = 'collapsed';
	}
	window.localStorage.setItem('webappSidebarCollapse', this.expandStatus);
}

function handleAddedChat() {
	console.log(this);
};

function handleCommandSetting(command) {
	console.log(this);
	console.log(command);
	if (command === 'about') {
		this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
			showConfirmButton: false,
			showCancelButton: false,
			type: 'warning',
			center: true
		}).then(() => {

		})
	}
};